import Main from './views/Main.vue'
import Home from './views/home/home.vue'
import UserList from './views/user/List.vue'
import UserAdd from './views/user/Add.vue'
// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
  path: '/login',
  name: 'login',
  meta: {
    title: 'Login - 登录'
  },
  component: resolve => { require(['./views/login.vue'], resolve) }
}

export const page404 = {
  path: '/*',
  name: 'error_404',
  meta: {
    title: '404-页面不存在'
  },
  component: resolve => { require(['./views/error_page/404.vue'], resolve) }
}

export const page401 = {
  path: '/401',
  meta: {
    title: '401-权限不足'
  },
  name: 'error_401',
  component: resolve => { require(['./views/error_page/401.vue'], resolve) }
}

export const page500 = {
  path: '/500',
  meta: {
    title: '500-服务端错误'
  },
  name: 'error_500',
  component: resolve => { require(['./views/error_page/500.vue'], resolve) }
}

export const preview = {
  path: '/preview',
  name: 'preview',
  component: resolve => { require(['./views/form/article-publish/preview.vue'], resolve) }
}

export const locking = {
  path: '/locking',
  name: 'locking',
  component: resolve => { require(['./views/main_components/locking-page.vue'], resolve) }
}

// 作为Main组件的子页面展示但是不在左侧菜单显示的路由写在otherRouter里
export const otherRouter = {
  path: '/',
  name: 'otherRouter',
  component: Main,
  children: [
    {
      path: 'home',
      title: '首页',
      name: 'home_index',
      component: resolve => { require(['./views/home/home.vue'], resolve) }
    },
    {
      path: 'ownspace',
      title: '个人中心',
      name: 'ownspace_index',
      component: resolve => { require(['./views/own-space/own-space.vue'], resolve) }
    },
    {
      path: 'user/add',
      title: '添加用户',
      name: 'user_manager_add',
      component: resolve => { require(['./views/user/Add.vue'], resolve) }
    },
    {
      path: 'user/edit',
      title: '编辑用户',
      name: 'user_manager_edit',
      component: resolve => { require(['./views/user/Edit.vue'], resolve) }
    },
    {
      path: 'order/:order_id',
      title: '订单详情',
      name: 'order_info',
      component: resolve => { require(['./views/advanced-router/component/order-info.vue'], resolve) }
    },  // 用于展示动态路由
    {
      path: 'shopping',
      title: '购物详情',
      name: 'shopping',
      component: resolve => { require(['./views/advanced-router/component/shopping-info.vue'], resolve) }
    },  // 用于展示带参路由
    {
      path: 'message',
      title: '消息中心',
      name: 'message_index',
      component: resolve => { require(['./views/message/message.vue'], resolve) }
    },
    {
      path: 'service/edit/:service_id',
      icon: 'plus-circled',
      name: 'service_edit',
      title: '服务详情',
      hidden: true,
      component: resolve => { require(['./views/service/Edit.vue'], resolve) }
    },
    {
      path: 'shop/category/add',
      icon: 'plus-circled',
      name: 'shop_category_add',
      title: '商品分类添加',
      hidden: true,
      component: resolve => { require(['./views/shop/category/Add.vue'], resolve) }
    },
    {
      path: 'shop/category/:category_id',
      icon: 'plus-circled',
      name: 'shop_category_edit',
      title: '商品分类详情',
      hidden: true,
      component: resolve => { require(['./views/shop/category/Edit.vue'], resolve) }
    },
    {
      path: 'advert/slider/add',
      icon: 'plus-circled',
      name: 'advert_slider_add',
      title: '轮播图添加',
      hidden: true,
      component: resolve => { require(['./views/advert/slider/Add.vue'], resolve) }
    },
    {
      path: 'shop/good/add',
      icon: 'plus-circled',
      name: 'shop_good_add',
      title: '商品添加',
      hidden: true,
      component: resolve => { require(['./views/shop/good/Add.vue'], resolve) }
    },
    {
      path: 'user/check/detail/:id',
      icon: 'plus-circled',
      name: 'user_update_check_detail',
      title: '审核详情',
      hidden: true,
      component: resolve => { require(['./views/user/CheckDetail.vue'], resolve) }
    },
  ]
}

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
export const appRouter = [
  {
    path: '/user',
    icon: 'ios-people',
    title: '用户管理',
    name: 'user_manager',
    component: Main,
    children: [
      {path: 'index', title: '用户管理', name: 'user_manager_index', component: UserList},
      {
        path: 'check',
        title: '师傅认证',
        name: 'user_update_check',
        component: resolve => { require(['./views/user/Check.vue'], resolve) }
      },
      {
        path: 'order',
        title: '订单管理员',
        name: 'user_manager_order',
        component: resolve => { require(['./views/user/AdminOrder.vue'], resolve) }
      }
    ]
  },
  {
    path: '/service',
    icon: 'social-buffer',
    name: 'service',
    title: '服务管理',
    component: Main,
    children: [
      {
        path: 'list',
        icon: 'ios-list',
        name: 'service_list',
        title: '服务列表',
        component: resolve => { require(['./views/service/List.vue'], resolve) }
      },
      {
        path: 'add',
        icon: 'plus-circled',
        name: 'service_add',
        title: '添加服务',
        hidden: true,
        component: resolve => { require(['./views/service/Add.vue'], resolve) }
      },
      {
        path: 'order',
        icon: 'ios-clock',
        name: 'service_order',
        title: '服务订单',
        hidden: true,
        component: resolve => { require(['./views/service/Order.vue'], resolve) }
      },
    ]
  },
  {
    path: '/shop',
    icon: 'ios-cart',
    name: 'shop',
    title: '商城管理',
    component: Main,
    children: [
      {
        path: 'category',
        title: '商品分类',
        name: 'shop-category',
        icon: 'pricetags',
        component: resolve => { require(['./views/shop/category/List.vue'], resolve) }
      },
      {
        path: 'good',
        title: '商品管理',
        name: 'shop-good-list',
        icon: 'bag',
        component: resolve => { require(['./views/shop/good/list.vue'], resolve) }
      }

    ]
  },
  {
    path: '/advert',
    icon: 'ios-analytics',
    name: 'advert',
    title: '广告管理',
    component: Main,
    children: [
      {
        path: 'slider',
        title: '轮播图',
        name: 'advert-slider',
        icon: 'ios-pie',
        component: resolve => { require(['./views/advert/slider/List.vue'], resolve) }
      },
      {
        path: 'adverts',
        title: '广告位',
        name: 'advert-adverts',
        icon: 'stats-bars',
        component: resolve => { require('./views/access/access.vue') }
      }
    ]
  },
  // {
  //   path: '/tables',
  //   icon: 'ios-grid-view',
  //   name: 'tables',
  //   title: '表格',
  //   component: Main,
  //   children: [
  //     {
  //       path: 'dragableTable',
  //       title: '可拖拽排序',
  //       name: 'dragable-table',
  //       icon: 'arrow-move',
  //       component: resolve => { require(['./views/tables/dragable-table.vue'], resolve) }
  //     },
  //     {
  //       path: 'editableTable',
  //       title: '可编辑表格',
  //       name: 'editable-table',
  //       icon: 'edit',
  //       component: resolve => { require(['./views/tables/editable-table.vue'], resolve) }
  //     },
  //     {
  //       path: 'exportableTable',
  //       title: '表格导出数据',
  //       name: 'exportable-table',
  //       icon: 'code-download',
  //       component: resolve => { require(['./views/tables/exportable-table.vue'], resolve) }
  //     },
  //     {
  //       path: 'table2image',
  //       title: '表格转图片',
  //       name: 'table-to-image',
  //       icon: 'images',
  //       component: resolve => { require(['./views/tables/table-to-image.vue'], resolve) }
  //     }
  //   ]
  // },
  // {
  //   path: '/advanced-router',
  //   icon: 'ios-infinite',
  //   name: 'advanced-router',
  //   title: '高级路由',
  //   component: Main,
  //   children: [
  //     {
  //       path: 'mutative-router',
  //       title: '动态路由',
  //       name: 'mutative-router',
  //       icon: 'link',
  //       component: resolve => { require(['./views/advanced-router/mutative-router.vue'], resolve) }
  //     },
  //     {
  //       path: 'argument-page',
  //       title: '带参页面',
  //       name: 'argument-page',
  //       icon: 'android-send',
  //       component: resolve => { require(['./views/advanced-router/argument-page.vue'], resolve) }
  //     }
  //   ]
  // },
  // {
  //   path: '/error-page',
  //   icon: 'android-sad',
  //   title: '错误页面',
  //   name: 'errorpage',
  //   component: Main,
  //   children: [
  //     {
  //       path: 'index',
  //       title: '错误页面',
  //       name: 'errorpage_index',
  //       component: resolve => { require(['./views/error_page/error-page.vue'], resolve) }
  //     }
  //   ]
  // }
]

// 所有上面定义的路由都要写在下面的routers里
export const routers = [
  loginRouter,
  otherRouter,
  preview,
  locking,
  ...appRouter,
  page500,
  page401,
  page404
]
